#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e6+10;
int T,n,m,L,ans,cnt;
double V;
int p[1000005],d[MAXN],v[MAXN],a[MAXN],num[1005][1005];
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	ios::sync_with_stdio(false);
	cin>>T;
	while(T--){
		ans=0;
		cin>>n>>m>>L>>V;
		memset(num,0,sizeof(num));
		memset(p,0,sizeof(p));
		memset(d,0,sizeof(d));
		memset(v,0,sizeof(v));
		memset(a,0,sizeof(a));
		int f=0;
		for(int i=1;i<=n;i++) {
			cin>>d[i]>>v[i]>>a[i];
			if(a[i]<0) f=1;
		}
		for(int i=1;i<=m;i++) cin>>p[i];
		for(int i=1;i<=n;i++){
			int dd=0;
			for(int j=1;j<=m;j++) if(p[j]>=d[i]) {dd=j;break;}
			if(v[i]>V&&a[i]>=0&&d[i]<=p[m]){ans++; }
			if(v[i]>V&&a[i]<0){
				double vv=(double)sqrt(v[i]*v[i]+2*a[i]*(p[dd]-d[i]));
				if(vv>V){ 
					ans++;
					
				}
			}
			if(v[i]<=V&&a[i]>0&&d[i]<p[m]){
				double vv=(double)sqrt(v[i]*v[i]+2*a[i]*(p[m]-d[i]));
				if(vv>V) {
					ans++;
					
					
				}
			}
		}
		cout<<endl<<ans;
		if (ans==0) cout<<" "<<m;
		else cout<<" "<<m-1;
	}
	return 0;
}
